// 案例一
// console.log('script start');

// setTimeout(function() {
//     console.log('promise1');
// }, 0);

// Promise.resolve().then(function() {
//     console.log('promise2');
// }).then(function() {
//     console.log('promise3');
// });
// console.log('script end');

// 'script start','script end''promise2''promise3''promise1'

// 案例二
console.log('script start')

async function async1() {
    await async2()
    console.log('async1 end')
}
async function async2() {
    console.log('async2 end')
}
async1()

setTimeout(function() {
    console.log('setTimeout')
}, 0)

new Promise(resolve => {
        console.log('Promise')
        resolve()
    })
    .then(function() {
        console.log('promise1')
    })
    .then(function() {
        console.log('promise2')
    })

console.log('script end');

// 'script start' 'async2 end' 'Promise'  script end  'promise1'  promise2   async1 end  setTimeout